#include<bits/stdc++.h>
using namespace std;
long long l,r,n;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	if(r-l>n-1) cout<<n-1;
	else {
		if(l==r) 
			cout<<l%n;
		else if(r%n<l%n)
			cout<<n-1;
		else if(r%n>l%n)
			cout<<r%n;
	}
	return 0;
}
